# /**
# * Copyright (c) 2022 Beijing Jiaotong University
# * photlab is licensed under [Open Source License].
# * You can use this software according to the terms and conditions of the [Open Source License].
# *
# * You may obtain a copy of [Open Source License] at: [https://open.source.license/]
# *
# * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# *
# * See the [Open Source License] for more details.
# */
# /**
# * Author: Shihao Xie
# * Created: Mar. 16, 2022
# * Supported by: National Key Research and Development Program of China
# */

namespace py phot_server.rpc.device_data_type

struct PhotGrid{
    1:optional i32 gridId,
    2:optional string name = "Grid",
    25:optional string grid_type = "2D",
    3:optional double xLength = 100,
    4:optional double yLength = 100,
    5:optional double zLength = 1,
    26:optional double waveLength = 1550e-9,
    6:optional double gridSpacing = 0.01,
    7:optional double totalTime = 1,
    8:optional double pmlWidthX = 1,
    9:optional double pmlWidthY = 1,
    10:optional double pmlWidthZ = 1,
    11:optional double permittivity_real = 1.0,
    27:optional double permittivity_imag = 1.0,
    12:optional double permeability = 1.0,
    13:optional double env_n = 1.0,
    28:optional string env_materials = "air",
    14:optional double courantNumber,
    15:optional string foldername = "fdtd",
    21:optional list<PhotSource> sources = [],
    22:optional list<PhotWaveguide> waveguides = [],
    23:optional list<PhotDetector> detectors = [],

    24:optional string gridPath,
    30:optional string parameters,
}

struct PhotSource{
    1:optional i32 sourceId,
    2:optional string sourceType = "pointsource",
    3:optional double period,
    4:optional double amplitude = 1.0,
    5:optional double phaseShift = 0.0,
    6:optional string name = "Source_1",
    7:optional bool pulse = false,
    8:optional string pulseType = "gaussian",
    9:optional double cycle = 5,
    10:optional double hanningDt = 10.0
    11:optional string polarization = "z",
    12:optional double pulse_length = 39e-15,
    13:optional double offset = 112e-15,
    14:optional double x = 50,
    15:optional double y = 50,
    16:optional double z = 50,
    17:optional double xLength,
    18:optional double yLength,
    19:optional double zLength,
    20:optional double waveLength,
    21:optional double x_start,
    22:optional double y_start,
    23:optional double z_start,
    24:optional double x_end,
    25:optional double y_end,
    26:optional double z_end,
    27:optional string waveform = "gaussian",
    30:optional string parameters,
}

struct PhotWaveguide{
    1:optional i32 waveguideId,
    2:optional string name = "Waveguide_1",
    3:optional string className = "Waveguide",
    4:optional double refractiveIndex = 1.7,
    5:optional PhotMaterial material,

    6:optional string parameters, // json

    # parameter in Waveguide(default = {200, 20}), Sbend{200, 100}, Ysplitter{200, 160},
    // DirectionalCoupler{200, 80}, Mmi{71, 56}
    10:optional double xLength,
    11:optional double yLength,
    # parameter in Waveguide(default = {20}), Sbend{20}, Ysplitter{20}, DirectionalCoupler{20},
    // Ring{20}, Mmi{20}, Arc{20}, Mzi{1}
    12:optional double zLength,
    # parameter in All waveguides
    13:optional double x,
    14:optional double y,
    15:optional double z,
    # parameter in Waveguide(default={10}), Sbend{20}, Ysplitter{20}, DirectionalCoupler{20}, Ring{20}, Arc{20}, Mzi{20}
    16:optional double width,

    # parameter in Sbend(enum = [1 (left top -> right bottom), -1 (left bottom -> right top)]),
    // Ysplitter [1 (single port point to negative X-axis direction), -1 (single port point to positive X-axis direction)],
    // DirectionalCoupler[1],
    // Ring[1],
    // Arc[1, 2, 3, 4]
    20:optional double direction,

    # parameter in Ysplitter(default={80}), DirectionalCoupler{50}
    30:optional double xLengthWaveguide,
    # parameter in Ysplitter
    31:optional double xLengthTaper, # default = 80,
    32:optional double yLengthTaper, # default = 80,
    33:optional double widthSbend, # default = 80,

    # parameter in DirectionalCoupler(default={10}), Ring{5}, Mzi{50}
    40:optional double gap, # default = 10,

    # parameter in Ring(default={100}), Arc{60}
    50:optional double outerRadius, # default = 100,
    # parameter in Ring(default={0}), Fiber{100}
    51:optional double length, # default = 0,

    # parameter in Mmi
    60:optional double We, # default = 56,
    61:optional double n, # default = 1,
    62:optional double m, # default = 2,
    63:optional double widthPort, # default = 25,
    64:optional double widthWg, # default = 20,
    65:optional double ln, # default = 20,
    66:optional double lm, # default = 20,
    67:optional double lPort, # default = 20,

    # parameter in Fiber
    70:optional string axis, # default = "x",
    71:optional list<double> radius, # default = [10,40],

    # parameter in Mzi
    80:optional double gapDc, # default = 10,
    81:optional double xlengthDc, # default = 150,
    82:optional double coupleLength, # default = 100,
    83:optional double coupleLengthDc, # default = 10,
    84:optional double addLengthArm1, # default = 0,
    85:optional double addLengthArm2, # default = 0,

    # parameter in FWG, Arc
    90:optional double angle_phi, # default =0
    91:optional double angle_psi, # default =0

    101:optional double xlength_upper,
    102:optional double xlength_lower,
    103:optional double zlength_waveguide,
    104:optional double xlength_taper,
    105:optional double xlength_sbend,
    106:optional double zlength_sbend,
    107:optional double width_sbend,
    108:optional double zlength_rectangle,
    109:optional double xlengxlength_sbend,
}

struct PhotDetector{
    1:optional i32 detectorId,
    2:optional string name,
    3:optional string detectorType = "linedetector",
    4:optional double x = 10,
    5:optional double y = 10,
    6:optional double z = 0,
    7:optional double xLength = 10,
    8:optional double yLength = 10,
    9:optional double zLength = 0,
    21:optional double x_start,
    22:optional double y_start,
    23:optional double z_start,
    24:optional double x_end,
    25:optional double y_end,
    26:optional double z_end,
    30:optional string parameters,
}

// 材料属性
struct PhotMaterialProperty{
    1:optional i32 propertyId = 1,
    2:optional double waveLength = 0.0175,
    3:optional double real = 0.8888,
    4:optional double imag = 0.0703,
}

// 材料类型
struct PhotMaterial{
    1:optional string name = "Au",
    2:optional string color = "#FFD700", // #FF0000
    3:optional list<PhotMaterialProperty> properties = [],
}

struct PhotFigure{
    1:optional string name,
    2:optional string axis,
    3:optional string type,
    4:optional string path,
    5:optional binary figure,
}